<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改邮路城市')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-dest-edit" th:object="${destbationCity}">
			<input hidden id="id" name="id" th:field="*{id}">
			<div class="form-group">
				<label class="col-sm-3 control-label ">邮路选择：</label>
				<div class="col-sm-8">
					<select name="destbationid" id="destbationid" th:with="type=${@dict.getType('pass_destbation')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:field="*{destbationid}"></option>
					</select>
				</div>
			</div>
			<input hidden id="cityid" name="cityid" th:field="*{cityid}">
			<div class="form-group">
				<label class="col-sm-3 control-label">城市名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="cityname" id="cityname" th:field="*{cityname}" required>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "system/dest";
	
		$("#form-dest-add").validate({
			onkeyup: false,
			rules:{
				cityname:{
					minlength: 1,
					remote: {
		                url: prefix + "/checkCityNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	name : function() {
		                        return $.common.trim($("#cityname").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
			},
			messages: {
		        "cityname": {
		            remote: "该城市名称已经存在"
		        }
		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            var formata = {"id":$("#id").val(),"destbationid":$("#destbationid").val(),"destbationvalue":$("#destbationid").find("option:selected").text(),"cityid":$("#cityid").val(),"cityname":$("#cityname").val()};
	        	$.operate.save(prefix + "/edit",formata);
	        }
	    }
	</script>
</body>
</html>
